<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">回收购物车</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">逻辑删除：</text></view>
                  <input type="number" placeholder="请输入逻辑删除" v-model="model.delFlag"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">时间戳：</text></view>
                  <input  placeholder="请输入时间戳" v-model="model.ts"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">租户id：</text></view>
                  <input type="number" placeholder="请输入租户id" v-model="model.tenantId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">用户id：</text></view>
                  <input  placeholder="请输入用户id" v-model="model.userId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">用户名：</text></view>
                  <input  placeholder="请输入用户名" v-model="model.userName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">回收id：</text></view>
                  <input  placeholder="请输入回收id" v-model="model.cycleId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">店铺id：</text></view>
                  <input  placeholder="请输入店铺id" v-model="model.shopId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">回收数量：</text></view>
                  <input type="number" placeholder="请输入回收数量" v-model="model.cycleNum"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">回收等级：</text></view>
                  <input  placeholder="请输入回收等级" v-model="model.evaluateLevel"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">评估价格：</text></view>
                  <input type="number" placeholder="请输入评估价格" v-model="model.evaluatePrice"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">回收价格：</text></view>
                  <input  placeholder="请输入回收价格" v-model="model.cyclePrice"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">商品id：</text></view>
                  <input  placeholder="请输入商品id" v-model="model.goodsId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">商品名称：</text></view>
                  <input  placeholder="请输入商品名称" v-model="model.goodsName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">商品价格：</text></view>
                  <input type="number" placeholder="请输入商品价格" v-model="model.goodsPrice"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">回收日期：</text></view>
                  <input  placeholder="请输入回收日期" v-model="model.cycleTime"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">到店方式：</text></view>
                  <input  placeholder="请输入到店方式" v-model="model.arriveType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">回收类型：</text></view>
                  <input  placeholder="请输入回收类型" v-model="model.cycleType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">商品图片：</text></view>
                  <input  placeholder="请输入商品图片" v-model="model.goodsPics"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">jancode：</text></view>
                  <input  placeholder="请输入jancode" v-model="model.jancode"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">需要imei标识：</text></view>
                  <input  placeholder="请输入需要imei标识" v-model="model.needimei"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">回收类别：</text></view>
                  <input  placeholder="请输入回收类别" v-model="model.cycleKinds"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">商品容量：</text></view>
                  <input  placeholder="请输入商品容量" v-model="model.goodsCap"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">商品颜色：</text></view>
                  <input  placeholder="请输入商品颜色" v-model="model.goodsColor"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">需要序列号标识：</text></view>
                  <input  placeholder="请输入需要序列号标识" v-model="model.needserialno"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否需要请求书：</text></view>
                  <input  placeholder="请输入是否需要请求书" v-model="model.overFlag"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">请求书1：</text></view>
                  <input  placeholder="请输入请求书1" v-model="model.filePath1"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">请求书2：</text></view>
                  <input  placeholder="请输入请求书2" v-model="model.filePath2"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">请求书3：</text></view>
                  <input  placeholder="请输入请求书3" v-model="model.filePath3"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否延迟支付：</text></view>
                  <input  placeholder="请输入是否延迟支付" v-model="model.delayPay"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">是否过期：</text></view>
                  <input  placeholder="请输入是否过期" v-model="model.expireFlag"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "TbCycleCartForm",
        components:{ myDate },
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/recycle/tbCycleCart/queryById",
                  add: "/recycle/tbCycleCart/add",
                  edit: "/recycle/tbCycleCart/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
